
const {DirImgList, sequelize} = require('../models/dirimglist');
const {DirList} = require('../models/dirlist');


async function submitDir(params) {

  let itemlist = []

  params.datalist.map(item => {

    item.shijian = new Date(item.shijian)
    item.dirpath = params.dirpath
    item.zhuangtai = '0'
    
    itemlist.push((item))
  })

  // await sequelize.sync({ force: true }); 
  await sequelize.sync({ alter: true }); 
  const newRecord = await DirImgList.bulkCreate(itemlist);

  let dirList = [{
    dirpath: params.dirpath,
    daxiao: params.daxiao,
    jindu: '0%',
    kaishitime: new Date(),
    haoshi: '0s'
  }]

  await DirList.bulkCreate(dirList);
}

exports.submitDir = submitDir